package com.ibm.spatiotemp.datamodel.datatype.request;

import com.ibm.spatiotemp.source.GPSDataSouceFactory;
import com.ibm.spatiotemp.source.GPSDataSource;

public class TSBuildIdxRequest extends BuildIdxRequest{

	public String tsid;
	
	public TSBuildIdxRequest(BuildIdxRequest ref, String tsid){
		this.setDatasrcid(ref.getDatasrcid());
		this.setRequesttype(ref.getRequesttype());
		this.setStartts(ref.getStartts());
		this.setEndts(ref.getEndts());
		this.setTsid(tsid);
	}
	
	public String getTsid() {
		return tsid;
	}

	public void setTsid(String tsid) {
		this.tsid = tsid;
	}
	
	public String getLineStringBuildingPath(String jobid){
		return datasrcid+"/"+tsid+"/"+jobid+"/"+"linestring";
	}
	
	/*2nd index layer path*/
	public String getRtreePath(){
		String dsrcname = this.getDatasrcid();
		GPSDataSource dsrc  = GPSDataSouceFactory.getGPSDataSource(dsrcname);
		long scale = dsrc.getIndexScale();
		long starts = this.getStartts() < dsrc.getMostEarlyTimeStamp() ? dsrc.getMostEarlyTimeStamp():this.getStartts();
		int scaled_startts = (int)((starts)/scale);
		return getSecondlayeridxpath() + tsid+ "/" + scaled_startts;
	}
}
